﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;

namespace Zxb.DayWork.Logic
{
    public class TotalCaseNum : BatchWorker
    {
        DataTable targetTable;
        bool quit = false;

        private static DataTable ReadDt_Estate_CaseNum()
        {
            string sql = "select RealEstateID,COUNT(1) as TotalNewCaseNum from Cases with(nolock) where IsValid=1 group by RealEstateID";
            return DAL.ReadDt_Retry_ReturnNewIfNull(DB.TaskReader, sql);
        }

        protected override void ReadData()
        {
            targetTable = ReadDt_Estate_CaseNum();
            if (targetTable.Rows.Count == 0)
            {
                quit = true;
                return;
            }
        }

        protected override void ProcessData()
        {

        }

        protected override void WriteData()
        {
            if (quit)
            {
                return;
            }

            bool flag = DAL.TVPUpdate(targetTable, "EstateManageUpdateTotalNewCaseNum", "UdtEstateManageUpdateTotalNewCaseNum");
        }
    }
}
